local zhixie = fk.CreateSkill{
    name = "ym_water__zhixie",
}
Fk:loadTranslationTable{
    ["ym_water__zhixie"] = "趾亵",
    [":ym_water__zhixie"] = "出牌阶段开始时，你可以令一名角色摸至多两张【毒】；下个出牌阶段开始时，你视为对其使用等量张【刮骨疗毒】。",
    ["#ym_water__zhixie"] = "是否对一名角色发动 趾袭？",
    ["ym_water__zhixie_active"] = "趾袭",
    ["ym_water__zhixie1"] = "摸一张【毒】",
    ["ym_water__zhixie2"] = "摸两张【毒】",
}

zhixie:addEffect(fk.EventPhaseStart,{
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(zhixie.name) and player.phase == Player.Play
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local bool, dat = room:askToUseActiveSkill(player,{
            skill_name = "ym_water__zhixie_active",
            prompt = "#ym_water__zhixie",
            skip = true,
        })
        if bool then
            event:setCostData(self, dat)
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).targets[1]
        local num = tonumber(string.sub(event:getCostData(self).interaction, 17, 17))
        room:doIndicate(player, {to})
        room:setEmotion(to, "./packages/water_wegame/image/anim/zhixie")

        local cards = {}
        while #cards < num do
            local card = room:printCard("es__poison", Card.Spade, table.random({4, 5, 9, 10}))
            table.insert(cards , card)
        end
        room:moveCardTo(cards, Card.PlayerHand, to, fk.ReasonDraw, zhixie.name, nil, true, to)

        local mark = player:getTableMark(zhixie.name)
        table.insert(mark,{to,num})
        room:setPlayerMark(player,zhixie.name,mark)
    end,

    can_refresh = function (self, event, target, player, data)
        return target == player and #player:getTableMark(zhixie.name) > 0 and player.phase == Player.Play
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        local mark = player:getTableMark(zhixie.name)
        for _, dat in ipairs(mark) do
            for i = 1, dat[2], 1 do
                room:useVirtualCard("scrape_poison",nil,player,{dat[1]},zhixie.name)
            end
        end
        room:setPlayerMark(player,zhixie.name,{})
    end,
})

return zhixie